/**
 * Created by Administrator on 2017-06-14.
 */
var driving = {
    init : function(){
       
        this.behavior=this.chartDriving(); //折线图
        this.mileage=this.chartMillage(); //条型图
        this.initVehicleList(); //加载权限车辆
        this.bind(); //绑定查询事件
        this.doSelTime(); //处理默认日期，现在最近7天的数据
        this.loadDetailsTitle(); //加载详情列表的表头
        this.bindExportExcel(); //绑定导出事件
        
        if(vid!=""&&vid!=null&&vid!="null"){
        	
        	this.queryVehicleRuning(); //如果车辆di就查询数据
        }
    },

    chartMillage : function(){
        var option = {

            tooltip : {
                trigger: 'axis',
                formatter: function (params) {
		            params = params[0];
		            return "日期:"+params.name+"<br/>"+"里程:"+params.value;
		        },
		        axisPointer: {
		        	animation: false
		        }
            },
            legend: {
                data:['行驶里程']
            },
            grid: {
		        left: '20px',
		        top:'10%',
		        right: '33px',
		        containLabel: true
		    },
            xAxis : [
                {
                    type : 'category',
                    boundaryGap : false,
                    data : []
                }
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : [
                {
                    name:'行驶里程',
                    type:'line',
                    stack: '总里程',
                    data:[]
                }
            ],
		    dataZoom: [{
		        type: 'inside',
		        start: 0,
		        end: 100
		    }, {
		        start: 0,
		        end: 100,
		        fillerColor:'#A3E1A3',
		        handleColor:'#83A7D1'
		    }]
        };
        var myChart = echarts.init(document.getElementById('chartMillage'));
        myChart.setOption(option);
        window.onresize = myChart.resize;
        return {
        	refash : function(option){
                myChart.setOption(option);
        	},
        	option : option,
        	chartMillageDom : myChart
        };
    },

    chartDriving : function(){
    	
        var option = {
            tooltip : {
                trigger: 'axis'
            },
            legend: {
                data:[]
            },
            grid: {
		        left: '3px',
		        top:'10%',
		        right: '33px',
		        containLabel: true
		    },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    data : []
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    minInterval: 1,
                    min:0,
                }
            ],
            series : [
                {
                    name:'报警类型',
                    type:'bar',
                    data:[]
                }
//                {
//                    name:'疲劳驾驶',
//                    type:'bar',
//                    data:[]
//                },
//                {
//                    name:'进出区域',
//                    type:'bar',
//                    data:[]
//                },
//                {
//                    name:'线路偏移',
//                    type:'bar',
//                    data:[]
//                },
//                {
//                    name:'进出地点',
//                    type:'bar',
//                    data:[]
//                }
               /* ,
                {
                    name:'其它报警',
                    type:'bar',
                    data:[]
                }*/
            ],
		    dataZoom: [{
		        type: 'inside',
		        start: 0,
		        end: 100
		    }, {
		        start: 0,
		        end: 100,
		        fillerColor:'#A3E1A3',
		        handleColor:'#83A7D1'
		    }]
        };
        var myChart = echarts.init(document.getElementById('chartDriving'));
        myChart.setOption(option);
        window.onresize = myChart.resize;
      
        //myChart.setOption(option);
        
        return {
        	refash : function(option){
                myChart.setOption(option);
        	},
        	option : option,
        	chartDrivingDom : myChart
        };
        
    },
    initVehicleList:function(){
    	$.ajax({
    		type : 'post',
    		async : false,
    		url : appCtx + "/system/vehicle/loadUserVehicle.html",
    		cache : false,
    		dataType : "JSON",
    		success : function(data) {			
    			if(data){
    				var selectStr="";
    				selectStr+="<option value=''>请选择</option>";
    				$.each(data.vehicleList,function(entryIndex,entry) {
    					selectStr+="<option value='"+entry.vehicleId+"'>"+entry.registrationNO+"</option>";
    				});
    				
    				$('#selectVehicleSel').html(selectStr);
    				$("#selectVehicleSel").val(vid);
    				$("#selectVehicleSel").select2();

    			}
    		}
    	});
    },
    queryVehicleRuning:function(){
      var _this = this;
      var startTime=$("#inputStartDate").val()+" 00:00:00";
   	  var endTime=$("#inputEndDate").val()+" 23:59:59";
   	  var vehicleId=$("#selectVehicleSel").val();
   	  
   	var end_str = (endTime).replace(/-/g,"/");//一般得到的时间的格式都是：yyyy-MM-dd hh24:mi:ss，所以我就用了这个做例子，是/的格式，就不用replace了。  
	var end_date = new Date(end_str);//将字符串转化为时间  
	//开始时间  
	var sta_str = (startTime).replace(/-/g,"/");  
	var sta_date = new Date(sta_str); 
	var num = (end_date-sta_date)/(1000*3600*24);//求出两个时间的时间差，这个是天数  
	var days = parseInt(Math.ceil(num));//转化为整天（小于零的话剧不用转了） 
	if(days>30){
		global.ajaxLoading.pop("查询时间不能超过30天",false,2000);
		return;
	}
	
   	  var url=appCtx+"report/vehicleRunning/getVehicleRunning.html?startTime="+startTime+"&endTime="+endTime+"&vehicleId="+vehicleId;
   	 if(vehicleId==null || vehicleId==""){
   		 global.ajaxLoading.pop("请选择车辆！", true, 2000);
   		 return false;
   	 }
   	global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
   	 $.post(url,function(data){
   		 var listVehicleRunning=data.listVehicleRunning;
   		 var listVehicleRunningDetails=data.listVehicleRunningDetails;
   		 dayObj=listVehicleRunningDetails;
   		 
   		 var ObjTableHtml="";
   		 $("#objTable").empty();
   		
   		 ObjTableHtml+="<tr id='objTitle'><th>车牌</th><th>自编号</th><th>车队</th><th>司机</th><th>总里程</th><th>行驶时长</th><th>图片</th><th>路段超速</th><th>夜间行车</th><th>车辆超速</th><th>疲劳驾驶</th></tr>"
   		 if(listVehicleRunning!=null&&listVehicleRunning.length>0){
   			 if(vehicleId!=null&&vehicleId!=""&&vehicleId!="null"){
   				var obj=listVehicleRunning[0];		 
   				ObjTableHtml+="<tr id='objInfo'>";
   				ObjTableHtml+="<td>"+obj.registrationNO+"</td>"+"<td>"+(typeof(obj.internalNumber)=="undefined"?"":obj.internalNumber)+"</td>"+"<td>"+(typeof(obj.vehicleTeam)=="undefined"?"":obj.vehicleTeam)+"</td>";
   				ObjTableHtml+="<td>"+(typeof(obj.driver)=="undefined"?"":obj.driver)+"</td>"+"<td>"+(obj.totalMileage)+"km</td>"+"<td>"+_this.doTimeFormat(obj.duration)+"</td>";
   				ObjTableHtml+="<td>"+obj.picCount+"</td>"+"<td>"+obj.totalRoadOverspeed+"</td>";
   				ObjTableHtml+="<td>"+obj.totalNightDriving+"</td>"+"<td>"+obj.totalVehicleSpeed+"</td>"+"<td>"+obj.totalVehicleTired+"</td>";				
   				ObjTableHtml+="</tr>";
   			 }
   			
   			 
   			
   		 }
   				 
   		
   	     var nightDrivingArr=[];
   	     var roadOverSpeedArr=[];
   	     var vehicleSpeedArr=[];
   	     var vehicleTiredArr=[];
   	     
   	     var titleArr=[];
   	   
   	     var dateArr=[];
   	     var mileageArr=[];
   	     
   	     var option = _this.behavior.option;
   	     var optionMileage=_this.mileage.option;
   	     
   	    
   	     var totalRoadOverspeed=0;
   	     var totalNightDriving=0;
   	     var totalVehicleSpeed=0;
   	     var totalVehicleTired=0;
   	     
   	     if(typeof(listVehicleRunningDetails)!="undefined"){
   	    	var dataRows= {
   	    			rows:listVehicleRunningDetails,
   	    			totol:listVehicleRunningDetails.length,
   	    			page:1
   	    			};
   	    	$("#ObjTableDetails").flexAddData(dataRows);
   	    	console.log($("#ObjTableDetails").getGridAllRows());
   	    	
   	    	 for(var i=0;i<listVehicleRunningDetails.length;i++){
   	   			 var obj=listVehicleRunningDetails[i];
   	   		    
   	   			 roadOverSpeedArr.push(obj.totalRoadOverspeed);
   	   			 nightDrivingArr.push(obj.totalNightDriving);
   	   		     vehicleSpeedArr.push(obj.totalVehicleSpeed);
   	   		     vehicleTiredArr.push(obj.totalVehicleTired);
   	   		     
   	   		     dateArr.push(obj.analyseDate);
   	   		     mileageArr.push(obj.totalMileage);  
   	   		     
	   	   		
   	   		     totalRoadOverspeed=totalRoadOverspeed+obj.totalRoadOverspeed;
   	   		     totalNightDriving=totalNightDriving+obj.totalNightDriving;
	      	     totalVehicleSpeed=totalVehicleSpeed+obj.totalVehicleSpeed;
	      	     totalVehicleTired=totalVehicleTired+obj.totalVehicleTired;
   	   		 }
   	    	 
   	    	 if(totalRoadOverspeed>=0){
   	    		 option.series[0]={
   	    				name:'道路超速' ,
   	    				type:'bar',
   	    		 		data:roadOverSpeedArr 	 
   	    		 };
  	    		 titleArr[0]='道路超速';
  	    	 }
   	    	 if(totalNightDriving>=0){
   	    		 option.series[1]={
   	    				name:'夜间行车' ,
   	    				type:'bar',
   	    		 		data:nightDrivingArr	 
   	    		 };
  	    		 titleArr[1]='夜间行车';
  	    	 }
   	    	 if(totalVehicleSpeed>=0){
   	    		 option.series[2]={
   	    				name:'超速' ,
   	    				type:'bar',
   	    		 		data:vehicleSpeedArr	 
   	    		 };
  	    		 titleArr[2]='超速';
  	    	 }
   	    	if(totalVehicleTired>=0){
   	    		option.series[3]={
   	    				name:'疲劳' ,
   	    				type:'bar',
   	    		 		data:vehicleTiredArr		
   	    		};
  	    		 titleArr[3]='疲劳';
  	    	 }
   	   		
   		    
   		    
   	    	option.legend.data=titleArr;
   	    	
   		     
   		     //option.series[5].data=otherAlarmArr;
   		     option.xAxis[0].data=dateArr;
   	   		_this.behavior.refash(option);
   	   		 
   	   		optionMileage.series[0].data=mileageArr;
   	   		optionMileage.xAxis[0].data=dateArr;
   	   		_this.mileage.refash(optionMileage); 
   	     }
   		
   		 
   		 
   		 $("#objTable").append(ObjTableHtml);
   		
   		global.ajaxLoading.close();
   	 },"json");
    },
    
    /**
     * 详情弹窗
     * */
    
    popNightDrivingModel : function(alarmType,dataRows){
    	global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
		$('#detailNightDrivingPop').modal('show');
		var params = {
                dataType : 'json',
                url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html",
                method: 'GET',
                params:[
                	{
                		alarmType : alarmType,
                		starDateTime : dataRows.analyseDate+" 00:00:00",
                		endDateTime:dataRows.analyseDate+" 59:59:59",
                		vehicleId:$("#selectVehicleSel").val()
                	}
                ],
                dataType : 'json',
                colModel :driving.getNightDrivingColumn(),
                resizable : false,
                usepager:false,          
                width : 'auto',// 表格宽度
                height : 330, // 表格高度
                //widthType:'%',
	            width:$('.detail-report').width(),
	            rp : 100000,
                autoload: true,
                sortname:'registrationNO',
                onSuccess : function(data){
                	global.ajaxLoading.close();
                },
                onSelectRow : function(row){
                               
                },
                onSelectAllRow : function(data){

                },
                onChangeSort : function(data){
                	console.log(data);
                }
            }
		if($("#detailNightDrivingTable").html() == ''){
			$("#detailNightDrivingTable").flexigrid(params);
		}else{
			$("#detailNightDrivingTable").flexOptions({
				params:[
                	{
                		alarmType : alarmType,
                		starDateTime : dataRows.analyseDate+" 00:00:00",
                		endDateTime:dataRows.analyseDate+" 59:59:59",
                		vehicleId:$("#selectVehicleSel").val()
                	}
                ],
                colModel:driving.getNightDrivingColumn()
			});
			$("#detailNightDrivingTable").flexReload();
		
		}
		
	
    },
	
	popRoadOverspeedModel : function(alarmType,dataRows){
	$('#detailRoadOverspeedPop').modal('show');	
	global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
	var params = {
            dataType : 'json',
            url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html",
            method: 'GET',
            params:[
            	{
            		alarmType : alarmType,
            		starDateTime : dataRows.analyseDate+" 00:00:00",
            		endDateTime:dataRows.analyseDate+" 59:59:59",
            		vehicleId:$("#selectVehicleSel").val()
            	}
            ],
            dataType : 'json',
            colModel :driving.getRoadOverspeedColumn(),
            resizable : false,
            usepager:false,          
            width : 'auto',// 表格宽度
            height : 340, // 表格高度
            //widthType:'%',
            width:$('.detail-report').width(),
            rp : 100000,
            autoload: true,
            sortname:'registrationNO',
            onSuccess : function(data){
            	global.ajaxLoading.close();
            },
            onSelectRow : function(row){
                           
            },
            onSelectAllRow : function(data){

            },
            onChangeSort : function(data){
            	//console.log(data);
            }
        }
	if($("#detailRoadOverspeedTable").html() == ''){
		$("#detailRoadOverspeedTable").flexigrid(params);
	}else{
		$("#detailRoadOverspeedTable").flexOptions({
			params:[
            	{
            		alarmType : alarmType,
            		starDateTime : dataRows.analyseDate+" 00:00:00",
            		endDateTime:dataRows.analyseDate+" 59:59:59",
            		vehicleId:$("#selectVehicleSel").val()
            	}
            ],
            colModel:driving.getRoadOverspeedColumn()
		});
		$("#detailRoadOverspeedTable").flexReload();
	
	}
	

	},
	popVehicleSpeedModel : function(alarmType,dataRows){
		global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
	$('#detailVehicleSpeedPop').modal('show');
	var vehicleId=$("#selectVehicleSel").val();
	var params = {
            dataType : 'json',
            url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html",
            method: 'GET',
            params:[
            	{
            		alarmType : alarmType,
            		starDateTime : dataRows.analyseDate+" 00:00:00",
            		endDateTime:dataRows.analyseDate+" 59:59:59",
            		vehicleId:vehicleId
            	}
            ],
            dataType : 'json',
            colModel :driving.getVehicleSpeedColumn(),
            resizable : false,
            usepager:false,          
            width : 'auto',// 表格宽度
            height : 330, // 表格高度
            //widthType:'%',
            width:$('.detail-report').width(),
            rp : 100000,
            autoload: true,
            sortname:'registrationNO',
            onSuccess : function(data){
            	global.ajaxLoading.close();
            },
            onSelectRow : function(row){
                           
            },
            onSelectAllRow : function(data){

            },
            onChangeSort : function(data){
            	//console.log(data);
            }
        }
	if($("#detailVehicleSpeedTable").html() == ''){
		$("#detailVehicleSpeedTable").flexigrid(params);
	}else{
		$("#detailVehicleSpeedTable").flexOptions({
			params:[
            	{
            		alarmType : alarmType,
            		starDateTime : dataRows.analyseDate+" 00:00:00",
            		endDateTime:dataRows.analyseDate+" 59:59:59",
            		vehicleId:vehicleId
            	}
            ],
            colModel:driving.getVehicleSpeedColumn()
		});
		$("#detailVehicleSpeedTable").flexReload();
	
	}
	

	},
	popVehicleTiredModel : function(alarmType,dataRows){
		global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
	$('#detailVehicleTiredPop').modal('show');
	var params = {
            dataType : 'json',
            url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html",
            method: 'GET',
            params:[
            	{
            		alarmType : alarmType,
            		starDateTime : dataRows.analyseDate+" 00:00:00",
            		endDateTime:dataRows.analyseDate+" 59:59:59",
            		vehicleId:$("#selectVehicleSel").val()
            	}
            ],
            dataType : 'json',
            colModel :driving.getVehicleTiredColumn(),
            resizable : false,
            usepager:false,          
            width : 'auto',// 表格宽度
            height : 330, // 表格高度
            //widthType:'%',
            width:$('.detail-report').width(),
            rp : 100000,
            autoload: true,
            sortname:'registrationNO',
            onSuccess : function(data){
            	global.ajaxLoading.close();
            },
            onSelectRow : function(row){
                           
            },
            onSelectAllRow : function(data){

            },
            onChangeSort : function(data){
            	//console.log(data);
            }
        }
	if($("#detailVehicleTiredTable").html() == ''){
		$("#detailVehicleTiredTable").flexigrid(params);
	}else{
		$("#detailVehicleTiredTable").flexOptions({
			params:[
            	{
            		alarmType : alarmType,
            		starDateTime : dataRows.analyseDate+" 00:00:00",
            		endDateTime:dataRows.analyseDate+" 59:59:59",
            		vehicleId:$("#selectVehicleSel").val()
            	}
            ],
            colModel:driving.getVehicleTiredColumn()
		});
		$("#detailVehicleTiredTable").flexReload();
	
	}
	

	},
	popVehiclePicModel : function(alarmType,dataRows){
		global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
		$('#detailVehiclePicop').modal('show');
		var params = {
	            dataType : 'json',
	            url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html",
	            method: 'GET',
	            params:[
	            	{
	            		alarmType : alarmType,
	            		starDateTime : dataRows.analyseDate+" 00:00:00",
	            		endDateTime:dataRows.analyseDate+" 59:59:59",
	            		vehicleId:$("#selectVehicleSel").val()
	            	}
	            ],
	            dataType : 'json',
	            colModel :driving.getVehiclePicColumn(),
	            resizable : false,
	            usepager:false,          
	            width : 'auto',// 表格宽度
	            height : 330, // 表格高度
	            //widthType:'%',
	            width:$('.detail-report').width(),
	            rp : 100000,
	            autoload: true,
	            sortname:'registrationNO',
	            onSuccess : function(data){
	            	global.ajaxLoading.close();
	            },
	            onSelectRow : function(row){
	                           
	            },
	            onSelectAllRow : function(data){

	            },
	            onChangeSort : function(data){
	            	//console.log(data);
	            }
	        }
		if($("#detailVehiclePicTable").html() == ''){
			$("#detailVehiclePicTable").flexigrid(params);
		}else{
			$("#detailVehiclePicTable").flexOptions({
				params:[
	            	{
	            		alarmType : alarmType,
	            		starDateTime : dataRows.analyseDate+" 00:00:00",
	            		endDateTime:dataRows.analyseDate+" 59:59:59",
	            		vehicleId:$("#selectVehicleSel").val()
	            	}
	            ],
	            colModel:driving.getVehiclePicColumn()
			});
			$("#detailVehiclePicTable").flexReload();
		
		}
		

		},
    bind:function(){
    	var _this=this;
    	$("#selVehicleRuning").click(function(){
    		_this.queryVehicleRuning();
    	});
    	
    	//关闭弹窗
    	/*$('#detailPop').find('.close,.closeBtn').click(function(){
    		$('#detailPop').modal('hide')
    	});*/
    },
    doSelTime:function(){
      var startTime=$("#inputStartDate").val();
      var endTime=$("#inputEndDate").val();
      
      if((startTime==null||startTime=="")&&(endTime==null||endTime=="")){
      	var todayDate = new Date();
      	todayDate = new Date(todayDate-86400000);
      	var todayDateStr=todayDate.getFullYear()+"-"+(todayDate.getMonth()+1)+"-"+todayDate.getDate();  
      	$("#inputEndDate").val(todayDateStr);
      	
      	var beforeDate = new Date(todayDate-86400000*3); //当前时间向前推7天
        var yyyy = beforeDate.getFullYear(), mm = (beforeDate.getMonth() + 1).toString(), dd = beforeDate.getDate().toString();
        if (mm.length == 1) {
             mm = '0' + mm;
        }
        if (dd.length == 1) {
             dd = '0' + dd;
        }
      	$("#inputStartDate").val(todayDateStr)
      }
    },
    getColumn:function(){
    	return [{
            display : '日期',
            name : 'analyseDate',
            width : 10,
            
            align : 'left'
        },{
            display : '总里程',
            name : 'totalMileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalMileage'],
            handlefunction:driving.doMileageFormat
        },{
            display : '行驶时长',
            name : 'duration',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['duration'],
            handlefunction:driving.doTimeFormat
        },{
            display : '图片',
            name : 'picCount',
            width : 10,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['picCount'],
            handlefunction:driving.changeColor
        },{
            display : '道路超速',
            name : 'totalRoadOverspeed',
            width : 10,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalRoadOverspeed'],
            handlefunction:driving.changeColor
          
        },{
            display : '夜间行车',
            name : 'totalNightDriving',
            width : 15,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalNightDriving'],
            handlefunction:driving.changeColor
           
        },{
            display : '车辆超速',
            name : 'totalVehicleSpeed',
            width : 10,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalVehicleSpeed'],
            handlefunction:driving.changeColor
           
        },{
            display : '疲劳驾驶',
            name : 'totalVehicleTired',
            width : 10,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalVehicleTired'],
            handlefunction:driving.changeColor
            
           
        }]
    },
    loadDetailsTitle:function(){
    	$("#ObjTableDetails").flexigrid({
	            dataType : 'json',
	            colModel :this.getColumn() ,
	            usepager : false,// 是否分页，默认为true。
	            height:330,
	            widthType:'%',
	            width:$('.detail-report').width(),
	            rp : 100000,
	            sortorder: 'desc',
	            sortable: true,
	            sortname:'registrationNO',
	            onSelectRow:function(rows,dataTitle){
	            	//console.log(rows,dataTitle);
	            	switch(dataTitle){
            		
            		case "totalVehicleSpeed":
            			driving.popVehicleSpeedModel(dataTitle,rows);
            			break;
            		case "totalVehicleTired":
            			driving.popVehicleTiredModel(dataTitle,rows);
            			break;
            		case "totalRoadOverspeed":
            			driving.popRoadOverspeedModel(dataTitle,rows);
            			break;
            		case "totalNightDriving":
            			driving.popNightDrivingModel(dataTitle,rows);
            			break;
            		case "picCount":
            			driving.popVehiclePicModel(dataTitle,rows);
            			break;	
            	}
	            },
                onChangeSort : function(data){
                	//console.log(data);
                }
	         });	 
    },
    exportExcel : function(){
		var header1 = JSON.stringify(driving.getColumn());
		var header2 = JSON.parse(header1);
		var headerWidth = $('.detail-report').width();
		for(var i=0;i<header2.length;i++){
			header2[i].width = Math.ceil(headerWidth / 100 * header2[i].width);
		}
		var header3 = JSON.stringify(header2);
		 var imageUrl = driving.behavior.chartDrivingDom.getDataURL({
			type: 'png',
		    pixelRatio: 1
		}); 
		 
		 var imageUrl2 = driving.mileage.chartMillageDom.getDataURL({
				type: 'png',
			    pixelRatio: 1
		}); 
		 
		//表头
		var colModelList=new Array();
		colModelList.push(header3);
		var colModel= $.toJSON(colModelList);
		
		//图片
		var imgsrcList=new Array();
		imgsrcList.push(imageUrl);
		imgsrcList.push(imageUrl2);
		var imgsrc= $.toJSON(imgsrcList);
			
		var totolTitle="";
		var totolInfo="";
		var sheetNameArr=['统计信息'];
		$("#objTitle th").each(function(index){
			totolTitle+=$.trim($(this).text())+",";
		});
		$("#objInfo td").each(function(){
			totolInfo+=$.trim($(this).text())+",";
		});
		totolTitle=totolTitle.substring(0,totolTitle.length-1);
		totolInfo=totolInfo.substring(0,totolInfo.length-1);
		/*var NewSheet={
				titleArr:{totolTitleArr},
				objArr:{totolTitle},
				sheetNameArr:sheetNameArr
		};*/
		var param =  {
			
				startTime:$("#inputStartDate").val(),  
				endTime: $("#inputEndDate").val()+" 59:59:59",  
				vehicleId:$("#selectVehicleSel").val(),
				newSheetName:'统计信息',
				totolTitle:totolTitle,
				totolInfo:totolInfo,
				colModel:colModel,
				title:"车辆行驶分析导出",
				imgsrc:imgsrc
		};
		
		post(appCtx+"report/vehicleRunning/exportVehicleRunning.html",param);
		
	},
	bindExportExcel:function(){
		var _this=this;
    	$("#exportExcel").click(function(){
    		_this.exportExcel();
    	});
	},
	getAreaInOutColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 10,
            sortable : true,
            align : 'left'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 10,
            sortable : true,
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 10,
            sortable : true,
            align : 'left'
        },{
            display : '进入时间',
            name : 'intodatetime',
            width : 10,
            sortable : true,
            align : 'left'
        },{
            display : '离开时间',
            name : 'outdatetime',
            width : 10,
            align : 'left',
            sortable:true
        },{
            display : '总时长',
            name : 'totaltime',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:driving.doTimeFormat
        },{
            display : '进入的经度',
            name : 'intolon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolon'],
            handlefunction:driving.doLatLngFormat
        },{
            display : '进入的纬度',
            name : 'intolat',
            width : 15,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolat'],
            handlefunction:driving.doLatLngFormat
        },{
            display : '进入的位置',
            name : 'inotposition',
            width : 10,
            
            align : 'left',
            sortable:true
          
        },{
            display : '离开的经度',
            name : 'outlon',
            width : 15,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlon'],
            handlefunction:driving.doLatLngFormat
           
        },{
            display : '离开的纬度',
            name : 'outlat',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlat'],
            handlefunction:driving.doLatLngFormat
           
        },{
            display : '离开的位置',
            name : 'outposition',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '区域名称',
            name : 'coveragename',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '分析器名称',
            name : 'analyseconditions',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '创建时间',
            name : 'createdatetime',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '进入里程',
            name : 'intomileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intomileage'],
            handlefunction:driving.doMileageFormat
            
            
        },{
            display : '离开里程',
            name : 'outmileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outmileage'],
            handlefunction:driving.doMileageFormat
            
            
        }]
	},
	getRadInoutColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 10,
            
            align : 'left'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 10,
            
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 10,
            
            align : 'left'
        },{
            display : '车辆颜色',
            name : 'platecolor',
            width : 10,
            
            align : 'left'
        },{
            display : '车队名称',
            name : 'motorcadename',
            width : 10,
            
            align : 'left',
            sortable:true
        },{
            display : '司机的身份证',
            name : 'drivericcode',
            width : 10,
            
            align : 'left',
            sortable:true
        },{
            display : '司机的名称',
            name : 'drivername',
            width : 10,
            
            align : 'left',
            sortable:true
        },{
            display : '司机的电话',
            name : 'driverphone',
            width : 15,
            
            align : 'left',
            sortable:true
           
        },{
            display : '进入的时间',
            name : 'intodatetime',
            width : 10,
            
            align : 'left',
            sortable:true
          
        },{
            display : '离开的时间',
            name : 'outdatetime',
            width : 15,
            
            align : 'left',
            sortable:true
           
        },{
            display : '运行时长',
            name : 'totaltime',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:driving.doTimeFormat
           
        },{
            display : '进入的经度',
            name : 'intolon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolon'],
            handlefunction:driving.doLatLngFormat
            
            
        },{
            display : '进入的纬度',
            name : 'intolat',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolat'],
            handlefunction:driving.doLatLngFormat
            
        },{
            display : '进入的位置',
            name : 'inotposition',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '离开的经度',
            name : 'outlon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlon'],
            handlefunction:driving.doLatLngFormat
            
        },{
            display : '离开的纬度',
            name : 'outlat',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlat'],
            handlefunction:driving.doLatLngFormat
            
            
        },{
            display : '离开的位置',
            name : 'outposition',
            width : 10,
            
            align : 'left',
            sortable:true
            
        },{
            display : '偏移条件名称',
            name : 'coveragename',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '进入里程',
            name : 'intomileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intomileage'],
            handlefunction:driving.doMileageFormat
            
            
        },{
            display : '进入的油耗',
            name : 'intooil',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '出去的油耗',
            name : 'outoil',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '分析条件名称',
            name : 'analyseconditions',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '创建时间',
            name : 'createdatetime',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '最大的偏移距离',
            name : 'maxoffsetdistance',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['maxoffsetdistance'],
            handlefunction:driving.doMileageFormat
            
            
        }]
	},
	getLocaleInoutColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 10,
            
            align : 'left'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 10,
            
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 10,
            
            align : 'left'
        },{
            display : '进入的日期',
            name : 'intodatetime',
            width : 10,
            
            align : 'left'
        },{
            display : '出去的日期',
            name : 'outdatetime',
            width : 10,
            
            align : 'left',
            sortable:true
        },{
            display : '运行时长',
            name : 'totaltime',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:driving.doTimeFormat
        },{
            display : '出去的经度',
            name : 'intolon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolon'],
            handlefunction:driving.doLatLngFormat
        },{
            display : '进去的纬度',
            name : 'intolat',
            width : 15,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolat'],
            handlefunction:driving.doLatLngFormat
           
        },{
            display : '出去的经度',
            name : 'outlon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlat'],
            handlefunction:driving.doLatLngFormat
          
        },{
            display : '出去的纬度',
            name : 'outlat',
            width : 15,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlat'],
            handlefunction:driving.doLatLngFormat
           
        },{
            display : '地点名称',
            name : 'coveragename',
            width : 10,
            
            align : 'left',
            sortable:true
           
        },{
            display : '分析条件名称',
            name : 'analyseconditions',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '创建时间',
            name : 'createdatetime',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '进去的里程',
            name : 'intomileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intomileage'],
            handlefunction:driving.doMileageFormat
            
            
        },{
            display : '出去的里程',
            name : 'outmileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outmileage'],
            handlefunction:driving.doMileageFormat
            
            
        }]
	},
	getVehicleSpeedColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 100,
            
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 150,
            
            align : 'left',
            showTitle : 'workUnitName'
        },{
            display : '开始时间',
            name : 'startdatetime',
            width : 120,
            
            align : 'left'
        },{
            display : '结束时间',
            name : 'enddatetime',
            width : 120,
            
            align : 'left',
            sortable:true
        },{
            display : '超速时长',
            name : 'totaltime',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:driving.doTimeFormat
        },{
            display : '最大速度',
            name : 'maxspeed',
            width : 80,
            
            align : 'left',
            sortable:true
        },{
            display : '最低速度',
            name : 'minspeed',
            width : 80,
            
            align : 'left',
            sortable:true
           
        },{
            display : '平均速度',
            name : 'averagespeed',
            width : 80,
            
            align : 'left',
            sortable:true
          
        },{
            display : '超速门限',
            name : 'speedthreshold',
            width : 60,
            
            align : 'left',
            sortable:true
           
        },{
            display : '超速类型',
            name : 'speedtype',
            width : 100,
            
            align : 'left',
            sortable:true
           
        },/*{
            display : '开始经度',
            name : 'startlon',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlon'],
            handlefunction:driving.doLatLngFormat
            
            
        },{
            display : '开始纬度',
            name : 'startlat',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlat'],
            handlefunction:driving.doLatLngFormat
            
            
        },*/{
            display : '开始位置',
            name : 'startposition',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlon','startlat','startdatetime'],
            handlefunction:driving.getAddressS
            
            
        },/*{
            display : '结束经度',
            name : 'endlon',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlon'],
            handlefunction:driving.doLatLngFormat
            
            
        },{
            display : '结束纬度',
            name : 'endlat',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlat'],
            handlefunction:driving.doLatLngFormat
            
            
        },*/{
            display : '结束位置',
            name : 'endposition',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlon','endlat','startdatetime'],
            handlefunction:driving.getAddressE	
            
            
        },{
            display : '分析条件名称',
            name : 'analyseconditions',
            width : 100,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '总里程',
            name : 'totalmileage',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalmileage'],
            handlefunction:driving.doMileageFormat
            
            
        }/*,{
            display : '创建时间',
            name : 'createdatetime',
            width : 120,
            
            align : 'left',
            sortable:true
            
            
        }*/]
	},
	getVehicleTiredColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 100,
            
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 150,
            
            align : 'left',
            showTitle : 'workUnitName'
        },{
            display : '开始时间',
            name : 'startdatetime',
            width : 120,
            
            align : 'left'
        },{
            display : '开始疲劳时间',
            name : 'starttiredtime',
            width : 120,
            
            align : 'left',
            sortable:true
            
            
            
        },{
            display : '结束时间',
            name : 'enddatetime',
            width : 120,
            
            align : 'left',
            sortable:true
        },{
            display : '疲劳值',
            name : 'timethreshold',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['timethreshold'],
            handlefunction:driving.doTimeFormatMin
        },{
            display : '疲劳驾驶时长',
            name : 'totaltime',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:driving.doTimeFormatTire
            
        }/*,{
            display : '开始经度',
            name : 'startlon',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlon'],
            handlefunction:driving.doLatLngFormat
           
        },{
            display : '开始纬度',
            name : 'startlat',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlat'],
            handlefunction:driving.doLatLngFormat

          
        }*/,{
            display : '开始位置',
            name : 'startposition',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlon','startlat','starttiredtime'],
            handlefunction:driving.getAddressS
           
        },/*{
            display : '结束经度',
            name : 'endlon',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlon'],
            handlefunction:driving.doLatLngFormat
           
        },{
            display : '结束纬度',
            name : 'endlat',
            width : 109,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlat'],
            handlefunction:driving.doLatLngFormat
            
            
        },*/{
            display : '结束位置',
            name : 'endposition',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlon','endlat','starttiredtime'],
            handlefunction:driving.getAddressE	
            
            
        },{
            display : '开始里程',
            name : 'startmileage',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startmileage'],
            handlefunction:driving.doMileageFormat
            
            
        },{
            display : '结束里程',
            name : 'endmileage',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endmileage'],
            handlefunction:driving.doMileageFormat
            
            
        },{
            display : '总里程',
            name : 'totalmileage',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalmileage'],
            handlefunction:driving.doMileageFormat
            
            
        },{
            display : '分析条件名称',
            name : 'analyseconditions',
            width : 100,
            
            align : 'left',
            sortable:true
            
            
        }/*,{
            display : '创建时间',
            name : 'createdatetime',
            width : 120,
            
            align : 'left',
            sortable:true
            
            
        }*/]
	},
	getVehiclePicColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNumber',
            width : 100,
            
            align : 'left'
        },{
            display : '拍照时间',
            name : 'gpsTimeStr',
            width : 150,
            
            align : 'left'
        }/*,{
            display : '拍照经度',
            name : 'longitude',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['longitude'],
            handlefunction:driving.doLatLngFormat
           
        },{
            display : '拍照纬度',
            name : 'latitude',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['latitude'],
            handlefunction:driving.doLatLngFormat

          
        }*/,{
            display : '拍照位置',
            name : 'picPosition',
            width : 400,
            
            align : 'left',
            sortable:true,
            paramcolnames:['longitude','latitude','gpsTimeStr'],
            handlefunction:driving.getAddressS
           
        }]
	},
	getRoadOverspeedColumn:function(){
		return [{ 
			display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            sortable:true,
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 150,
            sortable:true,
            align : 'left',
            showTitle : 'workUnitName'
        },{
            display : '道路类型名称',
            name : 'roadLevelName',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '超速时长',
            name : 'totaltime',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['totaltime'],
            handlefunction:driving.doTimeFormat
        },{
            display : '限速',
            name : 'limitspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '最高速度',
            name : 'maxspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '最低速度',
            name : 'minspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '平均速度',
            name : 'avgspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '开始时间',
            name : 'startdatetime',
            width : 120,
            sortable:true,
            align : 'left'
        },{
            display : '结束时间',
            name : 'enddatetime',
            width : 120,
            align : 'left',
            sortable:true
        },{
            display : '超速里程',
            name : 'over_speed_mileage',
            width : 100,
            align : 'left',
            sortable:true
        }/*,{
            display : '开始经度',
            name : 'startlon',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['startlon'],
            handlefunction:driving.doLatLngFormat
        },{
            display : '开始纬度',
            name : 'startlat',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['startlat'],
            handlefunction:driving.doLatLngFormat	
        },{
            display : '结束经度',
            name : 'endlon',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['endlon'],
            handlefunction:driving.doLatLngFormat
        },{
            display : '结束纬度',
            name : 'endlat',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['endlat'],
            handlefunction:driving.doLatLngFormat	
        }*/,{
            display : '开始位置',
            name : 'startposition',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['startlon','startlat','startdatetime'],
            handlefunction:driving.getAddressS	
        },{
            display : '结束位置',
            name : 'endposition',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['endlon','endlat','startdatetime'],
            handlefunction:driving.getAddressE	
        }]
        
	},
	getNightDrivingColumn:function(){
		 
	return [{ 
			display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            sortable:true,
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 100,
            sortable:true,
            align : 'left',
            showTitle : 'workUnitName'
        },{
            display : '分析器名称',
            name : 'analyseconditions',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '开始时间',
            name : 'startdatetime',
            width : 120,
            sortable:true,
            align : 'left'
        },{
            display : '结束时间',
            name : 'enddatetime',
            width : 120,
            align : 'left',
            sortable:true
        },{
            display : '最小速度',
            name : 'minspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '最大速度',
            name : 'maxspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '平均速度',
            name : 'averagespeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '速度门限',
            name : 'speedthreshold',
            width : 100,
            align : 'left',
            sortable:true
        }/*,{
            display : '开始经度',
            name : 'startlon',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['startlon'],
            handlefunction:driving.doLatLngFormat
        },{
            display : '开始纬度',
            name : 'startlat',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['startlat'],
            handlefunction:driving.doLatLngFormat	
        },{
            display : '结束经度',
            name : 'endlon',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['endlon'],
            handlefunction:driving.doLatLngFormat
        },{
            display : '结束纬度',
            name : 'endlat',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['endlat'],
            handlefunction:driving.doLatLngFormat	
        }*/,{
            display : '开始位置',
            name : 'startposition',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['startlon','startlat','startdatetime'],
            handlefunction:driving.getAddressS	
        },{
            display : '结束位置',
            name : 'endposition',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['endlon','endlat','startdatetime'],
            handlefunction:driving.getAddressE	
        },{
            display : '开始里程',
            name : 'startmileage',
            width : 100,
            align : 'left',
			sortable:true,
            paramcolnames:['startmileage'],
            handlefunction:driving.doMileageFormat
        },{
            display : '结束里程',
            name : 'endmileage',
            width : 100,
            align : 'left',
			sortable:true,
            paramcolnames:['endmileage'],
            handlefunction:driving.doMileageFormat
        },{
            display : '总耗时',
            name : 'totaltime',
            width : 100,
            align : 'left',
			sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:driving.doTimeFormat
        },{
            display : '夜间行驶里程',
            name : 'totalmileage',
            width : 100,
            align : 'left',
			sortable:true,
            paramcolnames:['totalmileage'],
            handlefunction:driving.doMileageFormat
        }/*,{
            display : '创建时间',
            name : 'createdatetime',
            width : 120,
            sortable:true,
            align : 'left'
        }*/]
	},
	doLatLngFormat:function(latOrLng){ //处理经纬度格式
		return (latOrLng/1000000);
	},
	doMileageFormat:function(mileage){ //处理里程格式
		return (mileage)+"km";
	},
	doTimeFormatMin:function(time){
		return (time/60)+"分钟";
	},
	doTimeFormatTire:function(ms){ //处理时间格式
		var timeStr="";  
		if(ms ==""||ms ==null||ms =="null"||typeof(ms)=="undefined"){
			return timeStr;
		}
	/*	 var hour =Math.floor(ms/3600000);  
		 var minute =Math.floor((ms-hour*3600000)/60000);  
		 var second=ms-hour*3600000-minute*60000;
		 var second = Math.floor((ms-hour*3600000-minute*60000)/1000);  
		 var milliSecond=ms-hour*3600000-minute*60000-second*1000;*/
		 var hour =Math.floor(ms/3600);  
		 var minute =Math.floor((ms-hour*3600)/60);  
		 var second=Math.floor(ms-hour*3600-minute*60);
		
	      
		 timeStr=hour+"小时"+minute+"分";
	   
	    return timeStr;
	},
	doTimeFormat:function(ms){ //处理时间格式
		var timeStr="";  
		if(ms ==""||ms ==null||ms =="null"||typeof(ms)=="undefined"){
			return timeStr;
		}
	/*	 var hour =Math.floor(ms/3600000);  
		 var minute =Math.floor((ms-hour*3600000)/60000);  
		 var second=ms-hour*3600000-minute*60000;
		 var second = Math.floor((ms-hour*3600000-minute*60000)/1000);  
		 var milliSecond=ms-hour*3600000-minute*60000-second*1000;*/
		 var hour =Math.floor(ms/3600);  
		 var minute =Math.floor((ms-hour*3600)/60);  
		 var second=Math.floor(ms-hour*3600-minute*60);
		
	      
		 timeStr=hour+"小时"+minute+"分"+second+"秒";
	   
	    return timeStr;
	},
	changeColor:function(value){ //改变字体颜色
		return "<span style='color:blue;'>"+value+"</span>"
	},getAddressS:function (start_lon,start_lat,id){
		id=id.replace(/[^0-9]/ig,""); 
		showAddress("spans"+id,(start_lon/1000000),(start_lat/1000000));
		return '<div id="spans'+id+'"><a href="#" >加载中..</a></div>';
  },getAddressE:function (start_lon,start_lat,id){
	  	id=id.replace(/[^0-9]/ig,""); 
		showAddress("spane"+id,(start_lon/1000000),(start_lat/1000000));
		return '<div id="spane'+id+'"><a href="#" >加载中..</a></div>';
}


	
};

driving.init();

function showAddress(id,start_lon,start_lat){
	var ctrl="#"+id;
	var geocoder = new AMap.Geocoder({
        radius: 1000,
        extensions: "all"
    });        
    geocoder.getAddress(new AMap.LngLat(start_lon,start_lat), function(status, result) {
        if (status === 'complete' && result.info === 'OK') {
        	var address=result.regeocode.formattedAddress;
        	$(ctrl).html(address);
        	$(ctrl).attr("title",address);
        }
    });    
}

